package main

import (
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {

	router := gin.Default()

	router.GET("/cookie", func(c *gin.Context) {

		cookie, err := c.Cookie("gin_cookie")

		if err != nil {
			cookie = "NotSet"
			c.SetCookie("gin_cookie", "test", 3600, "/", "127.0.0.1", false, true)
		}
		c.String(http.StatusOK, fmt.Sprintf("Cookie value: %s \n", cookie))
	})

	router.Run(":8080")
}
